package com.antipov.odp.pojo;

/**
 * Created with IntelliJ IDEA.
 * User: Andrew Antipov
 * Date: 18.02.14
 * Time: 21:49
 */
public class B extends A implements I {

	public static final int ID = 2;

	double d;

	public B(int[] array, int x, double d) {
		super(array, x);
		this.d = d;
	}

	@Override
	public int foo() {
		return super.foo() * (int) d;
	}

	public double getD() {
		return d;
	}

	public void setD(double d) {
		this.d = d;
	}

	@Override
	public String toString() {
		String res = "";
		res += ID;
		res += ' ';
		res += internalStateToString();
		res += ' ';
		res += d;
		return res;
	}

	@Override
	public boolean equals(Object obj) {
		if (this == obj) return true;
		if (obj == null || !(obj instanceof B)) return false;
		if (!super.equals(obj)) return false;

		B b = (B) obj;
		return Double.compare(b.d, d) == 0;
	}

	@Override
	public int hashCode() {
		int result = super.hashCode();
		long temp;
		temp = Double.doubleToLongBits(d);
		result = 31 * result + (int) (temp ^ (temp >>> 32));
		return result;
	}
}
